From: Florian Schmidt Date: Mon, 14 Aug 2017 16:31:39 +0000 (+0200) Subject: Move RawMessage out of Message.php to its own file X-Git-Tag: 1.31.0-rc.0~2389^2 X-Git-Url: http://git.cyclocoop.org/%7D%7Cconcat%7B?a=commitdiff_plain;h=499f643befc72f515f8f4b4bf984772b0f32a2b2;p=lhc%2Fweb%2Fwiklou.git Move RawMessage out of Message.php to its own file Change-Id: Idae9617dafa3c314085eb097f78f1c8d38672f31 --- diff --git a/autoload.php b/autoload.php index 508e75bdc8..d9e85bd39d 100644 --- a/autoload.php +++ b/autoload.php @@ -1180,7 +1180,7 @@ $wgAutoloadLocalClasses = [ 'RangeChronologicalPager' => __DIR__ . '/includes/pager/RangeChronologicalPager.php', 'RangeDifference' => __DIR__ . '/includes/diff/DiffEngine.php', 'RawAction' => __DIR__ . '/includes/actions/RawAction.php', - 'RawMessage' => __DIR__ . '/includes/Message.php', + 'RawMessage' => __DIR__ . '/includes/RawMessage.php', 'ReadOnlyError' => __DIR__ . '/includes/exception/ReadOnlyError.php', 'ReadOnlyMode' => __DIR__ . '/includes/ReadOnlyMode.php', 'ReassignEdits' => __DIR__ . '/maintenance/reassignEdits.php', diff --git a/includes/Message.php b/includes/Message.php index 8777c6fee1..0240fa7477 100644 --- a/includes/Message.php +++ b/includes/Message.php @@ -1344,56 +1344,3 @@ class Message implements MessageSpecifier, Serializable { return $this->extractParam( new RawMessage( $vars, $params ), $format ); } } - -/** - * Variant of the Message class. - * - * Rather than treating the message key as a lookup - * value (which is passed to the MessageCache and - * translated as necessary), a RawMessage key is - * treated as the actual message. - * - * All other functionality (parsing, escaping, etc.) - * is preserved. - * - * @since 1.21 - */ -class RawMessage extends Message { - - /** - * Call the parent constructor, then store the key as - * the message. - * - * @see Message::__construct - * - * @param string $text Message to use. - * @param array $params Parameters for the message. - * - * @throws InvalidArgumentException - */ - public function __construct( $text, $params = [] ) { - if ( !is_string( $text ) ) { - throw new InvalidArgumentException( '$text must be a string' ); - } - - parent::__construct( $text, $params ); - - // The key is the message. - $this->message = $text; - } - - /** - * Fetch the message (in this case, the key). - * - * @return string - */ - public function fetchMessage() { - // Just in case the message is unset somewhere. - if ( $this->message === null ) { - $this->message = $this->key; - } - - return $this->message; - } - -} diff --git a/includes/RawMessage.php b/includes/RawMessage.php new file mode 100644 index 0000000000..9a0d947dfd --- /dev/null +++ b/includes/RawMessage.php @@ -0,0 +1,72 @@ +message = $text; + } + + /** + * Fetch the message (in this case, the key). + * + * @return string + */ + public function fetchMessage() { + // Just in case the message is unset somewhere. + if ( $this->message === null ) { + $this->message = $this->key; + } + + return $this->message; + } + +}